package edu.rjxy.xjdx.emps.common;


import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class JSONUtil {
    public static void printJSON(Object obj, HttpServletResponse response) {
        response.setContentType("text/json;charset=utf-8");
        response.setCharacterEncoding("utf-8");
        try {
            PrintWriter out = response.getWriter();
            out.print(JSON.toJSONString(obj));//把java 对象转成json 格式定字符串
            out.flush();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
